package com.ios.common.exception;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ExceptionInterceptor implements MethodInterceptor {

	private final Log logger = LogFactory.getLog(this.getClass());

	public ExceptionInterceptor() {
	}

	public Object invoke(MethodInvocation invocation) throws Throwable {
		Object result = null;
		try {
			result = invocation.proceed();
		} catch (Exception e) {
			e.printStackTrace();
			if (!(e instanceof RuntimeException)) {
				logger.error("Exception " + e.getMessage(), e);
			}
			throw e;
		}
		return result;
	}
}
